<%@ page language="java"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <title>厂商管理</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>js/bootstrap-3.3.6/dist/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/bootstrapValidator.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/mydialog.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css"/>
    <script type="text/javascript" src="<%=basePath%>js/common/jquery-2.1.0.js" charset="utf-8"></script>

    <script type="text/javascript" src="<%=basePath%>js/common/dialog.3.1.min.js"></script>

<body>
<div id="index-hav2">
    <div class="index-hav-right" id="index-hav-right-clear">
        <div class="row">
            <div class="col-md-9">
                <span id="icon-house"> </span><span>首页</span>
                <span>></span><span>系统管理</span>
                <span>></span><span>厂商管理</span>
            </div>
            <div class="bank-box">
                <div class="lianlian platform">
                    <!-- 搜索 -->
                    <div class="col-md-12">
                        <form role="form" id="queryForm" method="post" action="<%=path%>/system/manufacturerManage/manufacturer/list">
                            <table class="textTable">
                                <tr>
                                    <td class="platform-start">厂商代码:</td>
                                    <th class="">
                                        <input type="text" class="form-control" name="orgCode"
                                               value="${map['orgCode'] }"/>
                                    </th>
                                    <td class="platform-start">厂商名称:</td>
                                    <th class="">
                                        <input type="text" class="form-control" name="orgName" value="${map['orgName'] }"/>
                                    </th>
                                </tr>
                                <tr>
                                </tr>
                            </table>
                            <ul class="textBtn">
                                <li class="">
                                    <button class="search-form-btn-s btn btn-primary btn-sm">查询</button>
                                    <button type="button" class="clearForm btn btn-primary btn-sm">重置</button>
                                    <button type="button" class="addRole btn btn-primary btn-sm" data-toggle="modal"
                                            data-target="#myModalAdd">新增厂商</button>
                                </li>
                            </ul>
                        </form>

                        <table class="control-tatle table table-striped table-bordered table-hover"
                               action="<%=path%>/system/manufacturerManage/manufacturer/list">
                            <thead class="financing-thead">
                            <tr>
                                <th style="width: 4%">序号</th>
                                <th style="width: 5%">厂商代码</th>
                                <th style="width: 5%">厂商名称</th>
                                <th style="width: 5%">登陆名</th>
                                <th style="width: 5%">联系人1</th>
                                <th style="width: 8%">联系电话1</th>
                                <th style="width: 8%">联系邮箱1</th>
                                <th style="width: 5%">联系人2</th>
                                <th style="width: 8%">联系电话2</th>
                                <th style="width: 8%">联系邮箱2</th>
                                <th style="width: 8%">联系邮箱3</th>
                                <th style="width: 8%">联系邮箱4</th>
                                <th style="width: 6%">状态</th>
                                <!-- <th style="width: 6%">创建人</th> -->
                                <th style="width: 6%">创建时间</th>
                                <!-- <th style="width: 6%">修改人</th> -->
                                <!-- <th style="width: 6%">修改时间</th> -->
                                <th style="width: 12%">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:if test="${not empty manufacturerList}">
                                <c:forEach items="${manufacturerList }" var="model" varStatus="r">
                                    <tr>
                                        <td>${r.index+1 }</td>
                                        <td>${model.orgCode }</td>
                                        <td>${model.orgName }</td>
                                        <td>${model.username }</td>
                                        <td>${model.linkMan }</td>
                                        <td>${model.linkPhone }</td>
                                        <td>${model.linkMail }</td>
                                        <td>${model.linkManTwo }</td>
                                        <td>${model.linkPhoneTwo }</td>
                                        <td>${model.linkMailTwo }</td>
                                        <td>${model.linkMailThree }</td>
                                        <td>${model.linkMailFour }</td>
                                        <td>
                                            <c:if test="${model.status == '1'}">启用</c:if>
                                            <c:if test="${model.status == '0'}">禁用</c:if>
                                        </td>
                                        <%-- <td>${model.insertedBy }</td> --%>
                                        <td><fmt:formatDate value="${model.insertedAt }" pattern="yyyy-MM-dd"/></td>
                                        <%-- <td>${model.updatedBy }</td> --%>
                                        <%-- <td><fmt:formatDate value="${model.updatedAt }" pattern="yyyy-MM-dd"/></td> --%>
                                        <td id="${model.id }">
                                            <a class="hand-like"
                                               href="<%=path%>/system/manufacturerManage/manufacturerById?id=${model.id }">修改
                                            </a>
                                            <span style="cursor:pointer;" class="hand-like" onclick="del(${model.id })">删除</span>
                                        </td>
                                        <input type="hidden" class="hiddenId" id="id" value="">
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${empty manufacturerList}">
                                <tr>
                                    <td colspan="15"><label class="control-label text-center">无记录</label>
                                        <div class="alert alert-warning" role="alert">
                                            <button class="btn btn-sm btn-success" data-toggle="modal"
                                                    data-target="#myModalAdd">
                                                新增厂商
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                            </c:if>
                            </tbody>
                            <tr style="background:#f8f8f8">
                                <td colspan="15">
                                    <jsp:include page="/WEB-INF/jsp/page.jsp"></jsp:include>
                                </td>
                            </tr>
                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 添加 模态框（Modal） -->
<div class="modal fade" id="myModalAdd" tabindex="-2" role="dialog" aria-labelledby="myModalLabelAdd"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h5 class="modal-title" id="myModalLabelAdd">
                    新增厂商
                </h5>
            </div>
            <form action="<%=path%>/system/manufacturerManage/updateOrAdd/manufacturer" id="defaultForm"
                  class="form-horizontal"
                  method="post">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">厂商代码:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="add_orgCode" name="orgCode"
                                   placeholder="Enter 厂商代码:" required/>
                        </div>

                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">厂商名称:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="add_orgName" name="orgName"
                                   placeholder="Enter 厂商名称:" required/>
                        </div>

                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">联系人1:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="add_linkMan" name="linkMan"
                                   placeholder="Enter 联系人1:" required/>
                        </div>

                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">联系电话1:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="add_linkPhone" name="linkPhone"
                                   placeholder="Enter 联系电话1:" required/>
                        </div>

                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">联系人2:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="add_linkMan2" name="linkManTwo"
                                   placeholder="Enter 联系人2:" required/>
                        </div>

                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">联系电话2:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="add_linkPhone2" name="linkPhoneTwo"
                                   placeholder="Enter 联系电话2:" required/>
                        </div>

                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">联系邮箱1:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="add_linkMail" name="linkMail"
                                   placeholder="Enter 联系邮箱1:" required/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">联系邮箱2:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="add_linkMailTwo" name="linkMailTwo" placeholder="Enter 联系邮箱2:" required/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">联系邮箱3:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="add_linkMailThree" name="linkMailThree" placeholder="Enter 联系邮箱3:" required/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">联系邮箱4:</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="add_linkMailFour" name="linkMailFour" placeholder="Enter 联系邮箱4:" required/>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <button type="submit" class="btn btn-sm btn-success">提交</button>
                </div>
            </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div><!-- /.end modal -->

<div id="gray-screen"></div>

</body>
<script type="text/javascript" src="<%=basePath%>js/validate/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/rem.js" charset="utf-8"></script>
<script type="text/javascript" src="<%=basePath%>js/validate/bootstrapValidator.js"></script>
<script type="text/javascript" src="<%=basePath%>js/validate/zh_CN.js"></script>
<script type="text/javascript" src="<%=basePath%>js/bootstrap-3.3.6/dist/js/bootstrap.min.js" charset="utf-8"></script>
<script>

    function del(id) {
        var flag = confirm("删除后将无法恢复,确定要删除?");
        if (flag) {
            //进行后台处理,路径跳转
            window.location.href = "<%=path%>/system/manufacturerManage/delete/manufacturer?id=" + id;
        } else {
            alert('已取消操作!');
        }
    }

</script>

<script type="text/javascript">
    $(document).ready(function () {
        //提交表单
        <%--$(".queryForm").click(function(){--%>
            <%--var data=$("#queryForm").serialize();--%>
            <%--window.location.href="<%=path%>/system/manufacturerManage/manufacturer/list?"+data;--%>
        <%--});--%>
        //清空搜索条件
        $(".clearForm").click(function(){
            $("#queryForm").find("input").val("");
            $("#queryForm").find("select").val("");
        });
        $('#defaultForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                parentId: {
                    validators: {
                        notEmpty: {}
                    }
                },
                linkMail: {
                    validators: {
                        notEmpty: {}
                    }
                },
            }
        }).on('success.form.bv', function (e) {
            // Prevent form submission
            e.preventDefault();
            // Get the form instance
            var $form = $(e.target)
            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');
            // Use Ajax to submit form data
            $.post($form.attr('action'), $form.serialize(), function (result) {
                var grayScreen = document.getElementById("gray-screen");
                Dialog({
                    "msg": '<div class="D_alert">' + result.message + '</div>',
                    "title": "提示",
                    "showButtons": true,
                    "cancelButton": false,
                    "onComplete": function () {
                        $("body").empty();
                        window.location.href = '<%=path%>/system/manufacturerManage/manufacturer/list';
                    }
                });
            }, 'json');
        });
    });
</script>
</html>